package com.example.demo.pattern.mixpattern.entity.duck.impl;

import com.example.demo.pattern.mixpattern.entity.duck.QuackAble;
import com.example.demo.pattern.mixpattern.observer.Observable;
import com.example.demo.pattern.mixpattern.observer.Observer;

//绿头鸭
public class MallardDuck implements QuackAble {
    private final Observable observable;

    public MallardDuck() {
        observable = new Observable(this);
    }

    @Override
    public void quack() {
        System.out.println("Quack");
        notifyObservers();
    }

    @Override
    public void registerObserver(Observer observer) {
        observable.registerObserver(observer);
    }

    @Override
    public void notifyObservers() {
        observable.notifyObservers();
    }
}
